<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *:focus{
            border: dashed 2px blue;
        }
    </style>
</head>
<body>
    <form action="">
        <a href="#" onblur="handleBlur(this)" onfocus="handleFocus(this)">demo1</a>
        <input type="text" placeholder="文本框" onblur="handleBlur(this)" onfocus="handleFocus(this)">
        <input type="password" placeholder="密码框" onblur="handleBlur(this)" onfocus="handleFocus(this)">
        <input type="radio" onblur="handleBlur(this)" onfocus="handleFocus(this)">
        <input type="checkbox" onblur="handleBlur(this)" onfocus="handleFocus(this)">
        <select onblur="handleBlur(this)" onfocus="handleFocus(this)">
            <option value="x">test</option>
        </select>
        <textarea onblur="handleBlur(this)" onfocus="handleFocus(this)"></textarea>
        <a href="#" onblur="handleBlur(this)" onfocus="handleFocus(this)">demo2</a>
    </form>
    <script>
        function handleBlur(e){
            console.log('失去焦点',e)
        }
        function handleFocus(e){
            console.log('获得焦点',e)
        }
    </script>
</body>
</html>